package org.xm.sk.vo.tb;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.xm.sk.vo.Base;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@Table(name = "dc_image")
@ApiModel(value = "Image", parent = Base.class, description = "图片")
public class Image extends Base {

    /**
     * 
     */
    private static final long serialVersionUID = -6336403995638840811L;

    @ApiModelProperty(value = "图片名称")
    @Column(length = 255)
    private String name;

    @ApiModelProperty(value = "图片文件地址")
    @Column(length = 255)
    private String uri;

    @ApiModelProperty(value = "图片信息")
    @JsonIgnore
    @Column
    @Lob
    @Basic(fetch = FetchType.EAGER)
    private byte[] file;

    @ApiModelProperty(value = "图片关联门店")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "images")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Shop> shops = new HashSet<Shop>(0);

    @ApiModelProperty(value = "展示图片关联发型师")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "images")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Hairdresser> hairdressers = new HashSet<Hairdresser>(0);

    @ApiModelProperty(value = "图片关联评论")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "images")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Mete> metes = new HashSet<Mete>(0);

    @ApiModelProperty(value = "图片关联活动")
    @JsonIgnore
    @ManyToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "images")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Activity> activitys = new HashSet<Activity>(0);

    @ApiModelProperty(value = "图片关联项目")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinTable(name = "dc_item_image", joinColumns = {
            @JoinColumn(name = "dc_image_id") }, inverseJoinColumns = {
                    @JoinColumn(name = "dc_item_id") })
    @Fetch(FetchMode.SUBSELECT)
    private Set<Item> items = new HashSet<Item>(0);

    @ApiModelProperty(value = "图片关联作品")
    @JsonIgnore
    @OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "image")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Works> workses = new HashSet<Works>(0);

    @ApiModelProperty(value = "用户头像")
    @JsonIgnore
    @OneToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "image")
    private User user;

}
